public class Test1 {
    public static void main(String[] args) {
        String s1 = " hello world ";
        System.out.println("{"+s1.trim()+"}");//只是去除字符串 最左侧和左右侧 的空格
    }
    public static void main8(String[] args) {
        String s = "helloworld";
        System.out.println(s.substring(5));//从指定位置截取到末尾
        System.out.println(s.substring(0,5));//从开始位置(参数一)截取到(参数二),范围是前闭后开区间
    }
    public static void main7(String[] args) {
        String s1 = "name=zhangsan&age=10";
        String[] s2 = s1.split("&");
        for (int i = 0; i < s2.length; i++) {
            String[] s3 = s2[i].split("=");
            for (int j = 0; j < s3.length; j++) {
                System.out.print(s3[j]);
            }
        }
    }
    public static void main6(String[] args) {
        String s1 = "192.163.1.1";
        String [] s2 = s1.split("\\.");//   \\.表示.
        for (String s:s2) {
            System.out.println(s);
        }
    }
    public static void main5(String[] args) {
        String s1 = "hello world";
        String [] s2 = s1.split(" ");//用空格作为分隔符
        for (String s:s2) {
            System.out.println(s);
        }
    }
    public static void main4(String[] args) {
        String s1 = new String("hello");
        System.out.println(s1.replace("l","ee"));//用ee(可以是字符或字符串) 替换o(可以是字符或者是字符串)
        System.out.println(s1.replaceAll("l","-"));//用- 替换所有l
        System.out.println(s1.replaceFirst("l","-"));//用- 替换第一个l
    }
    public static void main2(String[] args) {
        String s = String.format("%d / %d / %d",2025,8,1);
        System.out.println(s);
    }
    public static void main3(String[] args) {
        char[] ch = {'h','e','l','l','o'};
        String s1 = new String(ch);
        System.out.println(s1);
    }
    public static void main1(String[] args) {
        String s1 = "hello";
        char[] ch = s1.toCharArray();
        for (int i = 0; i < ch.length; i++) {
            System.out.print(ch[i]);
        }
    }
}
